package com.pets.springboot_petshop.mapper;

import com.pets.springboot_petshop.entity.Homecarousel;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface HomecarouselMapper {
    //id查询
    @Select("select * from homecarousel where id = #{id};")
    Homecarousel selectHomecarousel(int id);
    @Select("select * from homecarousel where name LIKE CONCAT('%', #{name}, '%');")
    List<Homecarousel> selectname(String name);
    //查询所有
    @Select("select * from homecarousel;")
    List<Homecarousel> findAll();
    //添加
    @Insert("insert into homecarousel(name,image_url,create_time,update_time)values(#{name},#{image_url},now(),now());")
    int addHomecarousel(Homecarousel homecarousel);
    //删除
    @Delete("delete from homecarousel where id=#{id};")
    int deleteHomecarouselById(int id);
    //修改数据
    @Update("UPDATE homecarousel SET name=#{name},image_url=#{image_url},update_time=now() where id= #{id};")
    int updateHomecarouselById(Homecarousel homecarousel);
}
